ConfiguredObject.GetSection Method [IIS 7 and higher]

Retrieves the contents of a configuration section for a configured object.

Syntax

ConfiguredObject.GetSection(SectionName, Section);
ConfiguredObject.GetSection SectionName, Section

Parameters

Name

Description

SectionName

A string variable that contains the name of the configuration section to be retrieved (for example, "BasicAuthenticationSection").

Section

A ConfigurationSection variable into which the contents of the configuration section are placed.

Return Value

This method does not return a value.

Remarks

You can use the GetSection method to retrieve the contents of a desired configuration section and set its configurable properties.

Note

The GetSection method signature contains an [IN] parameter for the section name and an [OUT] parameter for the section object that the method returns.

Example

The following example gets the HTTP errors section for the default Web site and displays both its array and non-array properties.

' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
' Get the default Web site.
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")

' Get the HTTP errors section by using the GetSection method.
oSite.GetSection "HttpErrorsSection", oSection

' Display a heading.
WScript.Echo "=============================="
WScript.Echo "Http Errors Section Properties"
WScript.Echo "=============================="

' Display the HttpErrorsSection non-array properties.
For Each vProp In oSection.Properties_
    If (vProp.Name <> "HttpErrors") And _
        (vProp.Name <> "SectionInformation") Then
        WScript.Echo vProp.Name & ": " & vProp.Value
    End If
Next
WScript.Echo 

' Display the HttpErrorsSection SectionInformation properties.
WScript.Echo "HttpErrorsSection.SectionInformation"
WScript.Echo "------------------------------------"
For Each vProp In oSection.SectionInformation.Properties_
    WScript.Echo vProp.Name & ": " & vProp.Value
Next
WScript.Echo

' Display the contents of the HttpErrors array property.
WScript.Echo "HttpErrorsSection.HttpErrors"
WScript.Echo "----------------------------"
For Each oHttpErrorElement In oSection.HttpErrors
    For Each vProp In oHttpErrorElement.Properties_
        WScript.Echo vProp.Name & ": " & vProp.Value
    Next
    WScript.Echo
Next

Requirements

Type

Description

Client

Requires IIS 7 on Windows Vista.

Server

Requires IIS 7 on Windows Server 2008.

Product

IIS 7

MOF file

WebAdministration.mof

See Also

Reference

ConfigurationSection Class [IIS 7 and higher]

ConfiguredObject Class [IIS 7 and higher]

HttpErrorElement Class [IIS 7 and higher]

HttpErrorsSection Class [IIS 7 and higher]